package org.anyin.gitee.cloud.center.websocket.handlers;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.handler.AbstractWebSocketHandler;
import org.springframework.web.socket.handler.TextWebSocketHandler;

@Component
@Slf4j
public class TextWebsocketHandler extends TextWebSocketHandler {

    @Override
    protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
        // super.handleTextMessage(session, message);
        String payload = message.getPayload();
        log.info("payload: {}", payload);

        TextMessage text = new TextMessage("server response");
        session.sendMessage(text);
    }
}
